/**
 * Created by asd73 on 2017/8/18.
 */
public class QuickSort {
    public int quickSort(int[] array,int lo,int hi){
        int tempDate;
        int middle;
        int i,j;
        i=lo;
        j=hi;
        middle=array[(i+j)/2];
        if (array[middle]>array[hi]){
            swap(array[middle],array[hi]);
        }
        if (array[lo]>array[hi]){
            swap(array[lo],array[hi]);
        }
        if (array[middle]>array[lo]){
            swap(array[middle],array[lo]);
        }
        int key=array[lo];
        while (lo<hi){
            hi--;
        }
        array[lo]=array[hi];
        while (array[lo]>=key && hi>lo){
            hi--;
        }
        array[lo]=array[hi];
        while(array[lo]<=key && hi>lo){
            lo++;
        }
        array[hi] = key;
        return hi;
    }
    public static void swap(int a,int b){
        int temp=a;
        a=b;
        b=temp;
    }

    public void sort(int[] array,int lo,int hi){
        if (lo>hi){
            return;
        }
        int index=quickSort(array,lo,hi);
        sort(array,lo,hi);
        sort(array,index+1,hi);
    }

    public static void main(String[] args){
        String[] strVoid=new String[]{"11","66","22","4","55","22","0","32"};
        int[] array1 = new int[strVoid.length];
        for (int i=0;i<strVoid.length;i++){
            array1[i]=Integer.parseInt(strVoid[i]);
        }
        QuickSort sort=new QuickSort();
        sort.sort(array1,0,strVoid.length-1);
        for(int i=0;i<strVoid.length;i++){
            System.out.print(strVoid[i]+" ");
        }
        System.out.println();
    }


}


